<?php include("admin-header.php"); ?>

<form action="edit2.php" method="post">
    <input type="hidden" name="questionMasterId" id="questionMasterId" value="<?php  echo $_POST['questionId']; ?>" />
    <input type="hidden" name="nestingLevel" id="nestingLevel" value="2"/>
   
    <input type="hidden" name="allIds" id="allIds" value="-1"/>

    <TABLE width =850px >
        <TR HEIGHT=80px >
            <TD width =40px >
            </TD>
            <TD>
                <TABLE cellspacing=0>
                    <TR>
                        <TD colspan="2"><input type="text" name="txt_focus" id="txt_focus" style="border:none;HEIGHT:1px" ><div id='createError' name='createError' class="style21"></div></TD>
                        

                    </TR>
                    <TR>
                        <TD COLSPAN=2 style="padding-top:20px"><h2>Create New Question : Level 1</h2></TD>

                    </TR>
                    <TR>
                        <TD>Question Title</TD>
                        <TD><input disabled type="text" name="questionTitle"  id="questionTitle"  value="<?php
                            $id = $_POST['questionId'];

                            if($id != null) {
                                $questionObj = DAOFactory::getQuestionmasterDAO()->load($id);
                                echo $questionObj->question;
                            }
                                   ?>" style="width:250px"></TD>

                    </TR>
                    <TR>
                        <TD colspan=2>&nbsp;</TD>

                    </TR>
                    <TR>
                        <TD>Category</TD>
                        <TD> <select disabled name="category" id="category"  <?php if($id != null) {
                                $categoryObj = DAOFactory::getCategorymasterDAO()->load($questionObj->categoryMasterId);

                                $selectedString = $categoryObj->categoryMasterId . "@@@@" . $categoryObj->categoryName . "@@@@" . $categoryObj->categoryDescription . "@@@@" . $categoryObj->position;

                            }

                                     ?> >
                                <option value="-1"> Select </option>
                                <?php
                                $arr = DAOFactory::getCategorymasterDAO()->queryAll();
                                for($i=0;$i<count($arr);$i++) {
                                    $row = $arr[$i];
                                    $currString = $row->categoryMasterId . "@@@@" . $row->categoryName . "@@@@" . $row->categoryDescription . "@@@@" . $row->position ;
                                    $str = "";
                                    if($currString == $selectedString) {
                                        $str = "selected=true" ;
                                    }

                                    echo  '<option ' . $str . ' value = "' . $currString . '" > ' .$row->categoryName . "</option>";
                                }

                                ?>
                            </select>

                        </TD>

                    </TR>
                    <TR>
                        <TD colspan=2>&nbsp;</TD>

                    </TR>
					                    <TR>
                        <TD>question url</TD>
                        <TD><input disabled type="text" name="url"  id="url"  value="<?php
                            $id = $_POST['questionId'];

                            if($id != null) {
                                $questionObj = DAOFactory::getQuestionmasterDAO()->load($id);
                                echo $questionObj->url;
                            }
                                   ?>" style="width:250px"></TD>

                    </TR>
                    <TR>
                        <TD colspan=2>&nbsp;</TD>

                    </TR>
                    <TR>
                        <TD>Initial Question</TD>
                        <TD>
                            <textarea  disabled rows="1" cols="30" name="initialQuestion"  id="initialQuestion"><?php if($id != null) {
                                    $firstLinkQuestionObj = DAOFactory::getQuestionmasterDAO()->load($questionObj->firstLink);
                                    echo	$firstLinkQuestionObj->question;
                                }
                                ?></textarea></TD>

                    </TR>
                    <TR>
                        <TD>&nbsp;</TD>
                        <TD>&nbsp;</TD>
                    </TR>
                    <TR >
                        <TD colspan=2 bgcolor="#EAEAEA">
                                            <?php
                                            
                                                if($id != null) {
                                                    if($questionObj->yesQuestionId != null) {
                                                        $yesQuestionObj = DAOFactory::getQuestionmasterDAO()->load($firstLinkQuestionObj->yesQuestionId);
                                                        $yestxt =  $yesQuestionObj->question;
                                                        $yesurl= $yesQuestionObj->url;
                                                        $yes = false;
                                                        if($yesQuestionObj->diagnosis !=null ) {
                                                            $yes = true;
                                                        }
                                                    }
                                                }
                                            ?>

                            <TABLE cellspacing=0>

                                <TR >
                                    <TD VALIGN="TOP" class=questionbox> <font size=2px>
									Yes Question :</font> 
                                    </TD>
                                    <TD VALIGN="TOP" class=questionbox>
                                        <textarea disabled  rows="1" cols="30" name="yesQuestion" <?php if($yes == true){ echo "disabled"; }  ?>  id="yesQuestion" ><?php echo $yestxt ?></textarea>
                                       
                                    </TD>
                                    <TD VALIGN="TOP" class=questionbox>
                                        <font size=2px>
                                            <input  disabled type="checkbox" name="yesQuestioncChkbox"  id="yesQuestioncChkbox" <?php if($yes == true) { echo "checked = 'checked'"; } ?> onclick="show('yesQuestion' ,'yesQuestioncChkbox', 'yesDiagnosis');" />&nbsp;<br> Final Answer
                                        </font>
                                    </TD>
                                    <TD VALIGN="TOP" class=questionbox>

                                        <textarea disabled  rows="1" cols="30" name="yesDiagnosis" <?php if($yes == true){}else{ echo "disabled"; }  ?>  id="yesDiagnosis"  ><?php if($yes == true) { echo $yesQuestionObj->diagnosis; } ?></textarea>
                                    </TD>
                                </TR>
                            
                               	<tr <?php if(!$urlConfiguration){?>style="display:none; " <?php }?> >
                                          <TD VALIGN="TOP" class=urlbox><font size=2px>
								Yes Question's Url : &nbsp;</font>
                                    </TD>
                                    <TD VALIGN="TOP" class="urlbox" colspan="3">
                                        <input type="text" disabled   name="yesQuestionUrl" id="yesQuestionUrl"  value="<?php echo $yesurl ?>" 	/>		
                                    </TD>
                                </tr>  
                            </TABLE>



                        </TD>
                    </TR>
                    <TR  >
                        <TD colspan=2 >

                            <TABLE  cellspacing=0>
                                <?php
                                            if($id != null) {
                                                if($questionObj->noQuestionId != null) {
                                                    $noQuestionObj = DAOFactory::getQuestionmasterDAO()->load($firstLinkQuestionObj->noQuestionId);
                                                    $notxt= $noQuestionObj->question;
                                                    $nourl= $noQuestionObj->url;
                                                    if($noQuestionObj->diagnosis !=null ) {
                                                        $no = "true";
                                                    }
                                                }
                                            }
                                            ?>

                                

                                <TR>
                                    <TD VALIGN="TOP" class=questionbox><font size=2px>
								No Question : &nbsp;</font>
                                    </TD>
                                    <TD VALIGN="TOP" class=questionbox>
                                        <textarea disabled  rows="1" cols="30" name="noQuestion" <?php if($no == true){ echo "disabled"; }  ?>  id="noQuestion"><?php echo $notxt ?></textarea>								<br>
                                    </TD>

                                    <TD VALIGN="TOP" class=questionbox>
                                        <font size=2px>
                                            <input disabled  type="checkbox"  name="noQuestioncChkbox"  id="noQuestioncChkbox"<?php if($no == true) { echo "checked"; } ?>  onClick="show('noQuestion' ,'noQuestioncChkbox', 'noDiagnosis');">&nbsp;<br> Final Answer<br>
                                        </font>
                                    </TD>
                                    <TD VALIGN="TOP" class=questionbox>
                                        <textarea  disabled rows="1" cols="30" name="noDiagnosis" <?php if($no == true){}else{ echo "disabled"; }  ?>  id="noDiagnosis"><?php if($no == true) { echo $noQuestionObj->diagnosis; } ?></textarea>
                                    </TD>
									
                                </TR>
								<TR <?php if(!$urlConfiguration){?>style="display: none; " <?php }?>>
                                    <TD VALIGN="TOP" class=urlbox><font size=2px>
								No Question's Url : &nbsp;</font>
                                    </TD>
                                    <TD VALIGN="TOP" class="urlbox" colspan="3" >
                                        <input  disabled type="text"  name="noQuestionUrl" id="noQuestionUrl"  value="<?php echo $nourl ?>" 	/>		<br>
                                    </TD>

                                   
									
                                </TR>
                            </TABLE>

                        </TD>
                    </TR>

 <TR>
                        <TD  class="questionbox">
                        </TD>
                        <TD  class="questionbox">
                            <input type="button" value=Edit  onclick="allowEdit()" style="color:white;font-weight:bold;float:right;background-color:#1A6A96;width:80px;height:25"/>
 

                        </TD>
                    </TR>
                    <TR>
                        <TD>
                            <br>

                        </TD>
                        <TD >
                        
                            <br>

                            <input type="submit" value="Next" style="color:white;font-weight:bold;float:right;background-color:#1A6A96;width:80px;height:25px" onclick="allowEdit();return validateCreate();" />


                        </TD>
                    </TR>
                </TABLE>
            </TD>
            <TD style="float:left">&nbsp;

            </TD>
        </TR>


        <TR>
            <TD COLSPAN=3><!-- end top table --></TD>
        </TR>

    </TABLE>

</form>
<?php include("footer.php"); ?>
